import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { NationalTreasureInfo } from "../../model/NationalTreasureInfo";
import { ObjectPool } from "../../../../com/gengine/utils/pools/ObjectPool";
import { NationalTreaCampScoreItem } from "./NationalTreaCampScoreItem";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../resource/ImagesConst";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GBox } from "../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../com/mui/containers/globalVariable/GBoxDirection";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
//class NationalTreaCampScoreView
    
    export  class NationalTreaCampScoreView extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(295, 160);
            title = Language.getString(41605);
            if (NationalTreaCampScoreView._instance) 
            {
                throw new Error("NationalTreaCampScoreView is a single");
            }
            return;
        }

        public updateData(arg1: NationalTreasureInfo): void
        {
            var loc4=null;
            var loc5=null;
            this.clear();
            var loc1=arg1.campScoreList;
            var loc2=0;
            var loc3=loc1.length;
            while (loc2 < loc3) 
            {
                loc4 = loc1[loc2];
                (loc5 = ObjectPool.getObject(NationalTreaCampScoreItem)).updateData(loc4, loc2 + 1);
                this._bodySprite.addChild(loc5);
                ++loc2;
            }
            this._bodySprite.invalidate();
            return;
        }

        public clear(): void
        {
            var loc1=null;
            while (this._bodySprite.numChildren > 0) 
            {
                loc1 = this._bodySprite.removeChildAt(0) as NationalTreaCampScoreItem;
                loc1.dispose();
                ObjectPool.disposeObject(loc1, NationalTreaCampScoreItem);
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._windowCenterB = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            addChild(this._windowCenterB);
            this._rankTxt = new Object /* flash.text.TextField */();
            this._rankTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._rankTxt.mouseEnabled = false;
            this._rankTxt.textColor = GlobalStyle.color1Uint;
            this._rankTxt.width = 50;
            this._rankTxt.text = Language.getString(27000);
            addChild(this._rankTxt);
            this._campTxt = new Object /* flash.text.TextField */();
            this._campTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._campTxt.mouseEnabled = false;
            this._campTxt.textColor = GlobalStyle.color1Uint;
            this._campTxt.width = 50;
            this._campTxt.text = Language.getString(27001);
            addChild(this._campTxt);
            this._totalTxt = new Object /* flash.text.TextField */();
            this._totalTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._totalTxt.mouseEnabled = false;
            this._totalTxt.textColor = GlobalStyle.color1Uint;
            this._totalTxt.width = 100;
            this._totalTxt.text = Language.getString(27002);
            addChild(this._totalTxt);
            this._lastTxt = new Object /* flash.text.TextField */();
            this._lastTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._lastTxt.mouseEnabled = false;
            this._lastTxt.textColor = GlobalStyle.color1Uint;
            this._lastTxt.width = 100;
            this._lastTxt.text = Language.getString(27003);
            addChild(this._lastTxt);
            this._line = GlobalClass.getScaleBitmap(ImagesConst.SplitLine);
            addChild(this._line);
            this._bodySprite = new GBox();
            this._bodySprite.direction = GBoxDirection.VERTICAL;
            this._bodySprite.verticalGap = 2;
            addChild(this._bodySprite);
            return;
        }

        protected /* override */ updateSize(): void
        {
            super.updateSize();
            _windowCenter.setSize(this.width - 22, this.height - titleHeight + 9);
            _windowCenter.x = 11;
            _windowCenter.y = 33;
            this._windowCenterB.setSize(_windowCenter.width - 8, _windowCenter.height - 8);
            this._windowCenterB.x = _windowCenter.x + 4;
            this._windowCenterB.y = _windowCenter.y + 4;
            this._rankTxt.x = this._windowCenterB.x + 6;
            this._rankTxt.y = this._windowCenterB.y + 4;
            this._campTxt.x = this._windowCenterB.x + 60;
            this._campTxt.y = this._rankTxt.y;
            this._totalTxt.x = this._windowCenterB.x + 120;
            this._totalTxt.y = this._rankTxt.y;
            this._lastTxt.x = this._windowCenterB.x + 200;
            this._lastTxt.y = this._rankTxt.y;
            this._line.width = this._windowCenterB.width;
            this._line.x = this._windowCenterB.x;
            this._line.y = this._rankTxt.y + this._rankTxt.textHeight + 4;
            this._bodySprite.x = this._windowCenterB.x;
            this._bodySprite.y = this._line.y + 6;
            return;
        }

        public static get instance(): NationalTreaCampScoreView
        {
            if (!NationalTreaCampScoreView._instance) 
            {
                NationalTreaCampScoreView._instance = new NationalTreaCampScoreView();
            }
            return NationalTreaCampScoreView._instance;
        }

        protected /* var */_windowCenterB: ScaleBitmap;

        protected /* var */_rankTxt: Object /* flash.text.TextField */;

        protected /* var */_campTxt: Object /* flash.text.TextField */;

        protected /* var */_totalTxt: Object /* flash.text.TextField */;

        protected /* var */_lastTxt: Object /* flash.text.TextField */;

        protected /* var */_line: ScaleBitmap;

        protected /* var */_bodySprite: GBox;

        /* internal */ static /* var */_instance: NationalTreaCampScoreView;
    }
